package com.museum.controller.api;

import com.alibaba.fastjson.JSONObject;
import com.museum.base.BaseResponse;
import com.museum.entity.DTO.user.UserAdd;
import com.museum.entity.DTO.user.UserLoginByName;
import com.museum.entity.DTO.user.UserQuery;
import com.museum.entity.DTO.user.UserRegister;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;


@Api(tags = "权限-用户管理")
public interface UserAPI {
    /**
     * 注册
     *
     * @return
     */
    @ApiOperation("用户注册")
    @PostMapping("register")
    BaseResponse<JSONObject> userRegister(@RequestBody @ApiParam(name = "用户注册", value = "每个字段都是必填！！", required = true)
                                                  UserRegister userRegister);

    /**
     * 根据token获取用户信息
     *
     * @param request
     * @return
     */
    @ApiOperation("根据token获取用户信息")
    @GetMapping("getUserInfo")
    BaseResponse<JSONObject> getMessage(HttpServletRequest request);

    /**
     * 退出登陆
     *
     * @return
     */
    @ApiOperation("退出登陆")
    @PostMapping("logout")
    BaseResponse<JSONObject> logout(HttpServletRequest request);

    /**
     * 根据token获取用户菜单
     *
     * @return
     */
    @ApiOperation("获取用户菜单")
    @GetMapping("getMenu")
    BaseResponse<JSONObject> getMenu(HttpServletRequest request);

    /**
     * 注册 用户名和密码登陆
     *
     * @return
     */
    @ApiOperation("用户登陆")
    @PostMapping("loginById")
     BaseResponse<JSONObject> userLoginByUserName(HttpServletRequest request, @RequestBody @ApiParam(name = "登陆", value = "每个字段都必填！！", required = true)
            UserLoginByName userLogin);

    /**
     * 添加用户
     *
     * @return
     */
    @Transactional
    @ApiOperation("添加用户")
    @PostMapping("addUser")
    BaseResponse<JSONObject> AddUser(HttpServletRequest request,@RequestBody @ApiParam(name = "添加用户") UserAdd userAdd);

    /**
     * 根据用户的userId 删除用户 同时删除关联的user_role表
     *
     * @return
     */
    @Transactional
    @ApiOperation("根据用户ID删除用户")
    @DeleteMapping("deleteUser/{userId}")
    BaseResponse<JSONObject> deleteId(HttpServletRequest request, @PathVariable("userId") Integer userId);

    /**
     * 查询所有用户
     *
     * @return
     */
    @ApiOperation("条件分页查询")
    @PostMapping("pageUserCondition/{current}/{limit}")
    BaseResponse<JSONObject> getAllUser(@PathVariable long current, @PathVariable long limit,
                                        @RequestBody(required = false) UserQuery userQuery,HttpServletRequest request);

    /**
     * 修改用户
     *
     * @return
     */
    @Transactional
    @ApiOperation("修改用户")
    @PutMapping("/updateUser")
    BaseResponse<JSONObject> updateUser(HttpServletRequest request, @RequestBody UserAdd user);



}
